<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of gscale</title>
  <meta name="keywords" content="gscale">
  <meta name="description" content="GSCALE adjusts the scale of an image.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- # RADOCCToolbox --><!-- menu.html CornerFinder -->
<h1>gscale
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>GSCALE adjusts the scale of an image.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function g=gscale(f,method,low,high) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> GSCALE adjusts the scale of an image.
 
 GSCALE returns the input image with the scale adjusted according to the
 input specifications.

 USAGE:
     g=gscale(f,'minmax'); adjusts the image to the default min and max of
     class of the input image
     
     g=gscale(f,'full8'); adjusts the image to a 8bit scale
 
     g=gscale(f,'full16'); adjsuts the image to a 16bit scale
 
 INPUTS:
     f: grayscale image (any class)
     method: scaling method
 
 OUTPUTS:
     g: adjusted image</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="findcorners.html" class="code" title="function imgcout=findcorners(img,debug)">findcorners</a>	FINDCORNERS is the main function called by the calibration GUI.</li><li><a href="getedges.html" class="code" title="function [imge,ix,iy]=getedges(img)">getedges</a>	GETEDGES gets the Sobel edge image.</li><li><a href="harris.html" class="code" title="function imgout=harris(img,win)">harris</a>	HARRIS obtains the Harris transform of image.</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function g=gscale(f,method,low,high)</a>
0002 <span class="comment">% GSCALE adjusts the scale of an image.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% GSCALE returns the input image with the scale adjusted according to the</span>
0005 <span class="comment">% input specifications.</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% USAGE:</span>
0008 <span class="comment">%     g=gscale(f,'minmax'); adjusts the image to the default min and max of</span>
0009 <span class="comment">%     class of the input image</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%     g=gscale(f,'full8'); adjusts the image to a 8bit scale</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%     g=gscale(f,'full16'); adjsuts the image to a 16bit scale</span>
0014 <span class="comment">%</span>
0015 <span class="comment">% INPUTS:</span>
0016 <span class="comment">%     f: grayscale image (any class)</span>
0017 <span class="comment">%     method: scaling method</span>
0018 <span class="comment">%</span>
0019 <span class="comment">% OUTPUTS:</span>
0020 <span class="comment">%     g: adjusted image</span>
0021 
0022 <span class="comment">% input error checking</span>
0023 <span class="keyword">if</span> ~exist(<span class="string">'f'</span>,<span class="string">'var'</span>) || isempty(f)
0024     error(<span class="string">'Please Input Image'</span>);
0025 <span class="keyword">end</span>
0026 <span class="keyword">if</span> ~exist(<span class="string">'method'</span>,<span class="string">'var'</span>) || isempty(method)
0027     error(<span class="string">'Please Specify Method'</span>);
0028 <span class="keyword">end</span>
0029 <span class="keyword">if</span> ~exist(<span class="string">'low'</span>,<span class="string">'var'</span>) || isempty(low)
0030     low=0;
0031 <span class="keyword">end</span>
0032 <span class="keyword">if</span> ~exist(<span class="string">'high'</span>,<span class="string">'var'</span>) || isempty(high)
0033     high=1;
0034 <span class="keyword">end</span>
0035 <span class="keyword">if</span> numel(low)&gt;1 || numel(high)&gt;1
0036     error(<span class="string">'Low and High should be scalars'</span>);
0037 <span class="keyword">end</span>
0038 <span class="keyword">if</span> low&gt;1 || low&lt;0 || high&gt;1 || high&lt;0
0039     error(<span class="string">'Low and High should be between 0 and 1'</span>);
0040 <span class="keyword">end</span>
0041 
0042 g=double(f);
0043 low=double(low);
0044 high=double(high);
0045 gmin=min(g(:));
0046 gmax=max(g(:));
0047 
0048 <span class="comment">%Adjust to [0,1]</span>
0049 g=(g-gmin)./(gmax-gmin);
0050 
0051 
0052 <span class="keyword">switch</span> method
0053     <span class="keyword">case</span> <span class="string">'full8'</span>
0054         g=im2uint8(g);
0055     <span class="keyword">case</span> <span class="string">'full16'</span>
0056         g=im2uint16(g);
0057     <span class="keyword">case</span> <span class="string">'minmax'</span>
0058         g=g.*(high-low)+low;
0059         <span class="keyword">switch</span> class(f)
0060             <span class="keyword">case</span> <span class="string">'uint8'</span>
0061                 g=im2uint8(g);
0062             <span class="keyword">case</span> <span class="string">'uint16'</span>
0063                 g=im2uint16(g);
0064             <span class="keyword">case</span> <span class="string">'double'</span>
0065                 g=im2double(g);
0066             <span class="keyword">otherwise</span>
0067                 error(<span class="string">'Unsupported Format, Supported Formats: unit8, uint16, double'</span>);
0068         <span class="keyword">end</span>
0069     <span class="keyword">otherwise</span>
0070         error(<span class="string">'Invalid Method'</span>);
0071 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Sun 04-Apr-2010 17:13:59 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>